// JavaScript Document
$(document).ready(function(){
	if($('#BannerSlide').length !== 0 ){
		$('#BannerSlide').XSlide({
			width:531,
			height:220,
			opacity:0,
			color:'#E94901',
			autohide:false
		});
	}
	$('li.LeftFloat-Bottom').click(function(){$(window).scrollTop(0);})
	
	$('div.LeftFloat-Into img').click(function(){
		AddFavorite(window.location,document.title)
	})
	function AddFavorite(sURL, sTitle) {   
		try {   
			window.external.addFavorite(sURL, sTitle);   
		} catch (e) {   
			try {   
				window.sidebar.addPanel(sTitle, sURL, "");   
			} catch (e) {   
				alert("加入收藏失败，请使用Ctrl+D进行添加");   
			}  
		}   
	}
	
	$('div.OnLineOpen img').css('cursor','pointer').click(function(){$('div.OnLine').slideDown('slow');})
	$('div.OnLineClose img').css('cursor','pointer').click(function(){$('div.OnLine').slideUp('slow');})
	
	var HotShop=$('div.HotShop')
	if ( HotShop.length != 0 ){
		HotShop.find(':first-child').addClass('HotShop-First');
		HotShop.find(':last-child').addClass('HotShop-Last')	
	}
	
	var ListWarp=$('div.List-Warp')
	if (ListWarp.length != 0){
		ListWarp.each(function(e){
			if ( e % 4 === 0 ){
				$(this).addClass('List-NoWarp');
			}
		})	
	}
	//热搜
	var SearchHot = $('div.Search-Hot');
	SearchHot.find('a').click(function(){
		$('#keyword').val( $(this).text() );
		$('#searchSub').click();
		return false;
	});
	
	var ShopSPic=$('div.ShopInfo-SPic');
	if(ShopSPic.length != 0 ){
		ShopSPic.find('img').click(function(){
			var src=$(this).attr('src');
			$('div.ShopInfo-Pic img').attr('src',src);	
		})	
	};
	var ShopBtn=$('div.ShopInfo-Btn');
	if(ShopBtn.length != 0 ){
		ShopBtn.hover(function(){
			$(this).css('background-color','#FFF1EB')	
		},function(){
			$(this).css('background-color','#F9F9F9')	
		})	
	}
	//首页选项卡
	var TabA=$('div.TabA')
	if (TabA.length != 0 ){
		TabA.click(function(){
			var index = TabA.index(this);
			TabA.removeClass('TabTitleOn');
			$(this).addClass('TabTitleOn');
			TabA.each(function(e){
				if ( e != index ){
					$('div.TabA'+e).hide();
				}else{
					$('div.TabA'+index).show();	
				}
			})	
		})
	}
	var TabB=$('div.TabB')
	if (TabB.length != 0 ){
		TabB.click(function(){
			var index = TabB.index(this);
			TabB.removeClass('TabTitleOn');
			$(this).addClass('TabTitleOn');
			TabB.each(function(e){
				if ( e != index ){
					$('div.TabB'+e).hide();
				}else{
					$('div.TabB'+index).show();	
				}
			})	
		})
	};
	//首页滚动
	var ScrollA=$('#Scroll1')
	if ( ScrollA.length == 1 ){
		$('#Scroll1L').css('cursor','pointer').click(function(){
			ScrollA.stop().animate({
				scrollLeft:"+=170"	
			},'slow');
		});
		$('#Scroll1R').css('cursor','pointer').click(function(){
			ScrollA.stop().animate({
				scrollLeft:"-=170"	
			},'slow');
		})
	}
	var ScrollB=$('#Scroll2')
	if ( ScrollA.length == 1 ){
		$('#Scroll2L').css('cursor','pointer').click(function(){
			ScrollB.stop().animate({
				scrollLeft:"+=170"	
			},'slow')	
		});
		$('#Scroll2R').stop().css('cursor','pointer').click(function(){
			ScrollB.animate({
				scrollLeft:"-=170"	
			})
		})
	}
	
})
//高级搜索参数配置
function SearchConfig(){
	var c = $("#ShopClass").val();
	var b = $("#ShopBrand").val();
	var form = $('#form1');
	var action = form.attr('action');
	if ( c!=0 ){ action += "&c="+c; }
	if ( b!=0 ){ action += "&b="+b; } 
	form.attr('action',action);
	return true;	
}
/*
var JSHtml='<dl class=\'promy clearfix\'>';
JSHtml += '<dt>我 要 买： </dt>';
JSHtml += '<dd><input type=\'text\' id=\'buynum\' value=\'1\' /><input type=\'hidden\' id=\'productID\' value=\'6\' /><input type=\'hidden\' id=\'standardIDs\' value=\'\' /><input type=\'hidden\' id=\'productDetailID\' value=\'\' /><input type=\'hidden\' id=\'StockNum\' value=\'\' />件 (<span class=\'count\' id=\'havenum\'>单价：--元</span>)</dd>';J
SHtml += '</dl>';
JSHtml += '';
JSHtml += '<dl class=\'choice clearfix\' id=\'choice_ok\'>';
JSHtml += '<dt>请选择： </dt>';
JSHtml += '<dd id=\'CurentChoice\'>';
JSHtml += '</dd>';
JSHtml += '</dl>';
JSHtml += ' ';
JSHtml += '<div class=\'buybtn\'>';
JSHtml += '<div class=\'btn-buy\'><img src=\'images/buy_now.jpg\' title=\'立即购买，点击此按钮，到下一步确认购买信息。\' onclick=\'GoToBuy();\' style=\'cursor:pointer;\'></div>';
JSHtml += '<div class=\'btn-add\'><img src=\'images/buy_car.jpg\' style=\'cursor:pointer;\' onclick=\'AddToShoppingCart();\' title=\'加入购物车\'></div>';
JSHtml += '</div>';
SetStandardHtml(standardAll,JSHtml);
*/